import { defineComponent, watch } from "vue";
import style from "./index.module.less";
import { useList } from "@/hooks";
import { listProps } from "./types";
export default defineComponent({
  name: "",
  props: listProps,
  setup(_) {
    const [list, listControl] = useList({
      url: _.url,
      params: _.params,
    });
    watch(
      () => _.params,
      (data) => {
        listControl.refresh(data);
      },
      { deep: true }
    );
    return () => {
      if (list.value.length > 0) {
        return <div class="list-type">{_.renderList(list.value)}</div>;
      } else {
        return _.renderEmpty();
      }
    };
  },
});
